/*
 *文章相关请求
 */
import request from "@/utils/request";

// 获取文章列表数据
export const getArticle = params => {
  return request({
    method: "GET",
    url: "/mp/v1_0/articles",
    //Body 参数使用 data设置
    //Query 参数使用 params设置
    //Headers 参数使用 headers设置
    params
  })
}

// 获取文章频道
export const getArticleChannels = () => {
  return request({
    method: "GET",
    url: "/mp/v1_0/channels",
  })
}

// 删除文章
export const delArticle = articleId => {
  return request({
    method: "DELETE",
    url: `/mp/v1_0/articles/${articleId}`
  })
}

// 发布文章
export const addArticle = (data, draft = false) => {
  return request({
    method: "POST",
    url: "/mp/v1_0/articles",
    params: {
      draft
    },
    data
  })
}

// 编辑文章
export const updateArticle = (articleId, data, draft = false) => {
  return request({
    method: "PUT",
    url: `/mp/v1_0/articles/${articleId}`,
    params: {
      draft
    },
    data
  })
}

// 编辑指定文章
export const getArticles = articleId => {
  return request({
    method: "GET",
    url: `/mp/v1_0/articles/${articleId}`,

  })
}
// 修改文章评论状态
export const updateCommentStatus = (articleId,allowComment) => {
  return request({
    method: "PUT",
    url: '/mp/v1_0/comments/status',
    params:{
          article_id:articleId
    },
    data:{
       allow_comment:allowComment 
    }

  })
}
